package com.zklh.leetcode.other.problem104;

class Solution {
    private int maxDepth = 0;

    public int maxDepth(TreeNode root) {
        down(root,0);
        return  maxDepth;
    }


    /**
     * 定义向下方法, 传入当前节点,和当前已经走过的深度
     * @param nowNode
     * @param nowDepth
     */
    private void down(TreeNode nowNode, int nowDepth){
        if(nowNode == null){
            maxDepth = nowDepth>maxDepth?nowDepth:maxDepth;
        }else{// 如果当前节点不空, 继续向下走, 有向左和向右两种路径
            down(nowNode.left,nowDepth+1);
            down(nowNode.right,nowDepth+1);
        }
    }

}
